import { AnimationClip } from 'cc'
import { State } from '../base/State'
import { StateMachine } from '../base/StateMachine'
import { SubStateMachine } from '../base/SubStateMachine'
import { DIRECTION_ENUM, DIRECTION_NUM_ENUM, ENTITY_STATE_ENUM } from '../enums'
import { PLAYER_ANIMATION_PATH } from '../utils/constants'

/** 子状态机 BlockTurnLeft */
export default class BlockTurnLeftSubStateMachine extends SubStateMachine {
  constructor(fsm: StateMachine) {
    super(fsm)
    // 保存左旋转时撞击的4个方向的状态机
    this.stateMachines.set(DIRECTION_ENUM.TOP, new State(fsm, PLAYER_ANIMATION_PATH.blockturnleftTop))
    this.stateMachines.set(DIRECTION_ENUM.BOTTOM, new State(fsm, PLAYER_ANIMATION_PATH.blockturnleftBottom))
    this.stateMachines.set(DIRECTION_ENUM.LEFT, new State(fsm, PLAYER_ANIMATION_PATH.blockturnleftLeft))
    this.stateMachines.set(DIRECTION_ENUM.RIGHT, new State(fsm, PLAYER_ANIMATION_PATH.blockturnleftRight))
  }

  run() {
    console.log(1111)
    const value = this.fsm.getParams(ENTITY_STATE_ENUM.DIRECTION) // 获取存储的方向值
    this.currentState = this.stateMachines.get(DIRECTION_NUM_ENUM[value as number]) // 根据方向值取出对应的状态机
  }
}
